package com.leyou.item.mapper;

import com.leyou.item.pojo.Stock;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import tk.mybatis.mapper.additional.idlist.DeleteByIdListMapper;
import tk.mybatis.mapper.additional.idlist.SelectByIdListMapper;
import tk.mybatis.mapper.additional.insert.InsertListMapper;
import tk.mybatis.mapper.common.Mapper;


/**
 * @Author: Rose
 * @Date: 2021/3/31 17:48
 * @version: 1.0.0
 */
public interface StockMapper extends Mapper<Stock>, InsertListMapper<Stock>, SelectByIdListMapper<Stock, Long>, DeleteByIdListMapper<Stock, Long> {

    @Update("UPDATE tb_stock set stock = stock - #{num} where sku_id = #{id} and stock >= #{num}")
    int decreaseStock(@Param("id") Long id, @Param("num") Integer num);

}
